<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8" />
		<title>{$lang.index_config}</title>
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<include file="common/ace-tag"/>
		<script src="/static/plugin/ace/js/jquery.autosize.min.js"></script>
		<script src="/static/plugin/ace/js/jquery.inputlimiter.1.3.1.min.js"></script>
	</head>

	<style>
		body{
			background-color:#fff;
		}
		.yui_right{
			float: right;
			margin-bottom: 20px;
		}
		.yui_email{
			width: 60%;
			height: 100%;
			margin-top: 50px;
			margin-left: 20%;
		}
	</style>
	<body >
	<div class="well yui_email">
		<div>
			<button class="btn btn-primary yui_right" style="display: <?php if (!in_array(str_replace('/','',$__url).'-save',think\Session::get('button-resource')) && think\Session::get('username')!='admin') { ?>  none <?php } ?>"" id="save">
				<i class="icon-plus align-top bigger-125"></i>
				{$lang.save}
			</button>
		</div>
		<div class="widget-main" style="margin-top: 50px">

			<input type="hidden" name="id" value="{$data.id}"/>

			<div>
				<label >{$lang_field['header']}</label>
				<input type="text" name="header" placeholder="{$lang_field['header']}" class="form-control" value="{$data.header}"/>
				<br>
			</div>

			<div>
				<label >{$lang_field.welcome}</label>
				<textarea class="autosize-transition form-control" name="welcome" >{$data.welcome}</textarea>
				<br>
			</div>

			<div>
				<label >{$lang_field.updatelog}</label>
				<textarea class="autosize-transition form-control" name="updatelog" >{$data.updatelog}</textarea>
				<br>
			</div>

			<div>
				<label >{$lang_field.about}</label>
				<textarea class="autosize-transition form-control" name="about" >{$data.about}</textarea>
				<br>
			</div>

			<div>
				<label >{$lang_field.copyright}</label>
				<textarea class="autosize-transition form-control" name="copyright" >{$data.copyright}</textarea>
				<br>
			</div>

		</div>
	</div>

	</body>

	<script>
		$(function () {

            $('textarea[class*=autosize]').autosize({append: "\n"});
            $('textarea.limited').inputlimiter({
                remText: '%n character%s remaining...',
                limitText: 'max allowed : %n.'
            });

            //修改
            $("#save").on('click' , function(){
                let id=$("input[name='id']").val();
                let header=$("input[name='header']").val();
                let welcome=$("textarea[name='welcome']").val();
                let updatelog=$("textarea[name='updatelog']").val();
                let about=$("textarea[name='about']").val();
                let copyright=$("textarea[name='copyright']").val();
                let loading = layer.load(1, {
                    shade: [0.1,'#fff']
                });
				//ajax提交数据
                $.post("{$__url}",
                    {
                        id:id,
                        header:header,
                        welcome:welcome,
                        updatelog:updatelog,
                        about:about,
                        copyright:copyright,
                    },
                    function(data,status){
                        if (data['code']==1){
                            layer.open({
                                title: '{$lang.notice}',
                                content: '{$lang.op_success}'
                                ,yes: function(index, layero){
                                    window.location.reload();
                                },cancel: function(){
                                    window.location.reload();
                                }
                            });
                        }else{
                            layer.msg(data['msg']);
                        }
                        layer.close(loading);
                	}, "json"
                );
            });
        });
	</script>

</html>
